<?php
$aksi="modul/slide/aksi_slide.php";
switch($_GET[act]){
  // Tampil Berita
  default:
?>
<h2>Slide Show</h2>
<?php echo "<input type=button value='Tambah Berita' onclick=\"window.location.href='?mod=slide&act=tambahslide';\">"; ?>
<table width="490" >
  <tr >
    <th width="20">No</th>
    <th width="144">Date</th>
    <th width="150">Gambar</th>
    <th width="156">Aksi</th>
  </tr>
 <?php 
 
 	$p      = new Paging;
    $batas  = 5;
    $posisi = $p->cariPosisi($batas);
 
 		$sql="select * from slide ORDER BY id_gambar DESC LIMIT $posisi,$batas ";
 		$query=@mysql_query($sql);
	$no=1 + $posisi;
		while ($data=@mysql_fetch_array($query)){
  ?>
   <tr class="<?php if ($no %2 == 0):echo "zebra";else:echo "zebra2"; endif;?>" align="center">
    <td><?php echo $no; ?></td>
    <td><?php echo tgl_indo($data['date']); ?></td>
    <td><img src="../image/<?php echo $data['nama_gambar']; ?>" width="150" height="50" /></td>
     <td align="center"><a href=?mod=slide&act=editslide&id=<?php echo "$data[id_gambar]"; ?>>Edit </a>| 
     <?php echo "<a href=$aksi?mod=slide&act=hapus&id=$data[id_gambar]&namafile=$data[nama_gambar]>"; ?>Hapus</a> </td>
  </tr>
  
 <?php 
 $no++;
 } ?>
</table>
<center><?php 
    $jmldata = mysql_num_rows(mysql_query("SELECT * FROM slide"));
    $jmlhalaman  = $p->jumlahHalaman($jmldata, $batas);
    $linkHalaman = $p->navHalaman($_GET[halaman], $jmlhalaman);

    echo "<div id=paging>$linkHalaman</div><br>";
break;
  case "tambahslide":
  ?>
  <h2>Tambah Gambar Slide</h2>
<?php echo "
  <form method=POST action='$aksi?mod=slide&act=input' enctype='multipart/form-data'>"; ?>
  <table width="370" >
    <tr>
      <td width="79">Pilih Gambar</td>
    
      <td width="275"><input type=file name='fupload' size=40></td>
   
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type=submit value=Simpan>
                            <input type=button value=Batal onclick=self.history.back()></td>
     
    </tr>
  </table>
  </form>
  
<?php break; 
 case "editslide":
 ?>
 <h2>Edit Gambar Slide</h2>
 <?php echo "
  <form method=POST action='$aksi?mod=slide&act=update' enctype='multipart/form-data'> 
    "; ?>
  
  <table width="370" border="1">
  <tr>
      <td width="79">Gambar</td>
    
    <td width="275"><?php 
	  
	  $id=$_GET['id'];
	  $sql="select * from slide where id_gambar=$id";
	  						$query=@mysql_query($sql);
							$d=@mysql_fetch_array($query); ?>
      <img src="../image/<?php echo $d['nama_gambar'] ?>" />
         <input type=hidden name=id value=<?php echo"$d[id_gambar]"; ?> />	
    </td>
   
    </tr>
    <tr>
      <td width="79">Pilih Gambar</td>
    
      <td width="275"><input type=file name='fupload' size=40></td>
   
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><input type=submit value=Simpan>
                            <input type=button value=Batal onclick=self.history.back()></td>
     
    </tr>
  </table>
  </form>
 <?php break; ?>
<?php } ?>